﻿using System.Linq.Expressions;

namespace FreeSql;

/// <summary>
/// 
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IRepositoryBase<TEntity, TKey> : IBaseRepository<TEntity, TKey> where TEntity : class
{
    /// <summary>
    /// 获得Dto
    /// </summary>
    /// <typeparam name="TDto"></typeparam>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<TDto> GetAsync<TDto>(TKey id);

    /// <summary>
    /// 根据条件获取实体
    /// </summary>
    /// <param name="exp"></param>
    /// <returns></returns>
    Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> exp);

    /// <summary>
    /// 根据条件获取Dto
    /// </summary>
    /// <param name="exp"></param>
    /// <returns></returns>
    Task<TDto> GetAsync<TDto>(Expression<Func<TEntity, bool>> exp);

 

}
/// <summary>
/// 
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public interface IRepositoryBase<TEntity> : IRepositoryBase<TEntity, long> where TEntity : class
{
}

/// <summary>
/// 
/// </summary>
public interface IRepositoryBase
{

}

public interface IRepositoryDefault<TEntity, TKey> : IRepositoryBase<TEntity, TKey> where TEntity : class
{
    /// <summary>
    /// 软删除
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<bool> SoftDeleteAsync(TKey id);


    /// <summary>
    /// 软删除
    /// </summary>
    /// <param name="predicate">条件</param>
    /// <returns></returns>
    Task<bool> SoftDeleteAsync(Expression<Func<TEntity, bool>> predicate);

    /// <summary>
    /// 批量删除
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<bool> SoftDeleteAsync(TKey[] id);



    /// <summary>
    /// 软恢复
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<bool> RecoveryAsync(TKey id);


    /// <summary>
    /// 软恢复
    /// </summary>
    /// <param name="predicate">条件</param>
    /// <returns></returns>
    Task<bool> RecoveryAsync(Expression<Func<TEntity, bool>> predicate);

    /// <summary>
    /// 批量恢复
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<bool> RecoveryAsync(TKey[] id);
}


public interface IRepositoryDefault<TEntity> : IRepositoryDefault<TEntity, long> where TEntity : class
{
}
